package sch.frog.utils.mail;

import java.util.ArrayList;
import java.util.List;

public class Mail {
	private String from;	//发件邮箱
	
	private StringBuilder toAddress = new StringBuilder();	//收件邮箱列表
	private StringBuilder ccAddress = new StringBuilder();	//抄送人列表
	private StringBuilder bccAddress = new StringBuilder();	//暗抄人列表
	
	private String subject = "default name";	//邮件主题(标题), 必须填否则有可能被当做垃圾邮件
	private String content;	//邮件正文
	
	List<AttachFile> fileList = new ArrayList<AttachFile>();	//附件列表
	
	public Mail() {
		super();
	}

	public Mail(String from, String toAddress){
		this(from, toAddress, null, null);
	}
	
	public Mail(String from, String toAddress, String subject, String content) {
		super();
		this.from = from;
		this.toAddress.append(toAddress);
		this.subject = subject;
		this.content = content;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getToAddress() {
		return toAddress.toString();
	}

	public void addToAddress(String toAddress) {
		if(this.toAddress.length() > 0){
			this.toAddress.append(",");
		}
		this.toAddress.append(toAddress);
	}

	public String[] getCcAddress() {
		if(ccAddress.length() > 0) return ccAddress.toString().split(",");
		return null;
	}

	public void addCcAddress(String ccAddress) {
		if(this.ccAddress.length() > 0){
			this.ccAddress.append(",");
		}
		this.ccAddress.append(ccAddress);
	}

	public String[] getBccAddress() {
		if(bccAddress.length() > 0)	return bccAddress.toString().split(",");
		else return null;
	}

	public void addBccAddress(String bccAddress) {
		if(this.bccAddress.length() > 0){
			this.bccAddress.append(",");
		}
		this.bccAddress.append(bccAddress);
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public List<AttachFile> getFileList() {
		return fileList;
	}

	public void addAttachFile(AttachFile attachFile) {
		this.fileList.add(attachFile);
	}
	
}
